Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SONiC Yang model support for COPP #7199

Merged
merged 9 commits into from
Jun 29, 2021
Merged

Conversation

amaneti
Copy link
Contributor

@amaneti amaneti commented Mar 31, 2021

Why I did it

Created SONiC Yang model for COPP.
Tables: COPP_GROUP, COPP_TRAP.

How I did it

Defined Yang models for COPP based on Guideline doc:
https://github.com/Azure/SONiC/blob/master/doc/mgmt/SONiC_YANG_Model_Guidelines.md
and
https://github.com/Azure/sonic-utilities/blob/master/doc/Command-Reference.md

How to verify it

$ pytest tests/yang_model_tests/test_yang_model.py -v
============================================================================== test session starts ===============================================================================
platform linux2 -- Python 2.7.13, pytest-3.0.6, py-1.4.32, pluggy-0.4.0 -- /usr/bin/python
cachedir: .cache
rootdir: /sonic/src/sonic-yang-models, inifile:
plugins: cov-2.4.0
collected 1 items

tests/yang_model_tests/test_yang_model.py::Test_yang_models::test_run_tests PASSED

============================================================================ 1 passed in 0.50 seconds ============================================================================


module: sonic-copp
  +--rw sonic-copp
     +--rw COPP_GROUP
     |  +--rw COPP_GROUP_LIST* [name]
     |     +--rw name                    string
     |     +--rw queue?                  uint32
     |     +--rw trap_priority?          uint32
     |     +--rw trap_action             stypes:copp_packet_action
     |     +--rw meter_type              stypes:meter_type
     |     +--rw mode                    enumeration
     |     +--rw color?                  enumeration
     |     +--rw cir?                    uint64
     |     +--rw cbs?                    uint64
     |     +--rw pir?                    uint64
     |     +--rw pbs?                    uint64
     |     +--rw green_action?           stypes:copp_packet_action
     |     +--rw yellow_action?          stypes:copp_packet_action
     |     +--rw red_action?             stypes:copp_packet_action
     |     +--rw genetlink_name?         string
     |     +--rw genetlink_mcgrp_name?   string
     +--rw COPP_TRAP
        +--rw COPP_TRAP_LIST* [name]
           +--rw name          string
           +--rw trap_ids      string
           +--rw trap_group?   -> /sonic-copp/COPP_GROUP/COPP_GROUP_LIST/name

  rpcs:
    +---x get-match-protocols
       +--ro output
          +--ro Match_protocols* [Protocol]
             +--ro Protocol    string


Which release branch to backport (provide reason below if selected)

  • 201811
  • 201911
  • 202006
  • 202012

Description for the changelog

A picture of a cute animal (not mandatory but encouraged)

@amaneti amaneti requested a review from lguohan as a code owner March 31, 2021 07:38
@lguohan
Copy link
Collaborator

lguohan commented Mar 31, 2021

can you split the test cases?

@lguohan lguohan added the YANG YANG model related changes label Mar 31, 2021
@lguohan lguohan requested a review from prsunny March 31, 2021 19:19
@prsunny
Copy link
Contributor

prsunny commented Mar 31, 2021

@dgsudharsan to review

@amaneti
Copy link
Contributor Author

amaneti commented Apr 3, 2021

retest please

}

leaf trap_ids {
type string;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be enum?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Response here


leaf red_action {
type string {
pattern "(drop)|(forward)|(copy)|(copy_cancel)|(trap)|(log)|(deny)|(transit)" {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be enum?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

}
}
description
"CPU queue id";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-> cpu rx queue id

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

}

leaf trap_ids {
type string;
Copy link
Contributor

@prsunny prsunny Apr 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CoPP HLD expects the trap_ids name to be specific string. Should we define a pattern here, something based on this?

Copy link
Contributor Author

@amaneti amaneti Apr 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trap_ids is a string with comma separated trap_ids.

"arp": {
            "trap_ids": "arp_req,arp_resp,neigh_discovery",
            "trap_group": "queue4_group3"
 },

If we have to define a pattern based on copporch,
trap_ids can be defined as leaf-list in yang i.e array.

leaf-list trap_ids {
                    mandatory true;
                    type enumeration {
                        enum arp_req;
                        enum arp_resp;
                        enum arp_suppress;
                        ...
                        ...
                        enum vrrp;
                        enum vrrpv6;
                    }
                    description "list of trap_ids";
            }

But, this would also mandate

  1. changes to copp_cfg.j2 trap_ids fields as below:
"arp": {
            "trap_ids": [
                "arp_req",
                "arp_resp",
                "neigh_discovery"
            ],
            "trap_group": "queue4_group2"
        },
  1. changes to coppmgr to handle array of trap_ids. Otherwise, it results into ERR swss#coppmgrd: :- main: Runtime error: type must be string, but is array

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok. im not expecting a change to coppmgr or template.

leaf queue {
type uint8 {
range "0..47" {
error-message "Invalid value passed for queue";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason why the range is restricted to 48 queues? Is there any restriction imposed in SAI regarding the maximum number of queues?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed range "0..47" {


leaf trap_priority {
type uint16 {
range "0..1023" {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the SAI headers the range is dependent on platforms. I am not sure why the priority is restricted to 0-1023
*
* @type sai_uint32_t
* @flags CREATE_AND_SET
* @default attrvalue SAI_SWITCH_ATTR_ACL_ENTRY_MINIMUM_PRIORITY
* @validonly SAI_HOSTIF_TRAP_ATTR_PACKET_ACTION == SAI_PACKET_ACTION_TRAP or SAI_HOSTIF_TRAP_ATTR_PACKET_ACTION == SAI_PACKET_ACTION_COPY
*/
SAI_HOSTIF_TRAP_ATTR_TRAP_PRIORITY

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed range "0..1023" {

"Red action";
}

leaf genetlink_name {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If genetlink name and mc_group name are exposed to north bound interfaces to be modified what is the purpose of restricting here to a single value?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

genetlink_name and genetlink_mcgrp_name are applicable to sFlow only. Current supported values are "psample" and "packets" respectively. Default copp_cfg.j2 does have these defined. However, user may chose to create a new copp_group COPP_GROUP|sflow-group and bind it to COPP_TRAP|sflow. Hence these fields are defined in yang and restricted to allowed patterns (psample, packets).

genetlink_name       = genetlink_name ;[Optional] "psample" for sFlow 
genetlink_mcgrp_name = multicast group name; ;[Optional] "packets" for sFlow 

@dgsudharsan, Are you suggesting not to expose these fields through yang ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do not expose these to user as these are internal implementations. I am not sure why an external user would be interested in specifying details about internal communication mechanisms. @prsunny Please let me your thoughts on this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, I think genetlink part can be removed from Yang and it is internal.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed leaf genetlink_name and leaf genetlink_mcgrp_name

"Control plane policing trap name";
}

leaf trap_ids {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this mandatory field ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

"Red action";
}

leaf genetlink_name {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this leaf needed ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Response here

@amaneti
Copy link
Contributor Author

amaneti commented Apr 27, 2021

retest this please

dgsudharsan
dgsudharsan previously approved these changes May 6, 2021
@anshuv-mfst
Copy link

@arlakshm , @prsunny - please initiate retest, thanks

prsunny
prsunny previously approved these changes May 20, 2021
@lguohan lguohan dismissed stale reviews from prsunny and dgsudharsan via 2fcbf84 June 9, 2021 21:12
@anand-kumar-subramanian
Copy link
Contributor

retest please

@arlakshm
Copy link
Contributor

@amaneti, can you resolve the conflicts

@amaneti
Copy link
Contributor Author

amaneti commented Jun 15, 2021

@arlakshm - conflicts are resolved.

prsunny
prsunny previously approved these changes Jun 16, 2021
@arlakshm
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

dgsudharsan
dgsudharsan previously approved these changes Jun 17, 2021
@amaneti
Copy link
Contributor Author

amaneti commented Jun 18, 2021

@arlakshm, @anshuv-mfst - rebased, build passed.
@dgsudharsan @prsunny @lguohan - please review.

@prsunny
Copy link
Contributor

prsunny commented Jun 18, 2021

can you please resolve the conflict?

**- What I did**

Created SONiC Yang model for COPP.
Tables: COPP_GROUP, COPP_TRAP.

**- How I did it**
Defined Yang models for COPP based on Guideline doc:
https://github.com/Azure/SONiC/blob/master/doc/mgmt/SONiC_YANG_Model_Guidelines.md
and
https://github.com/Azure/sonic-utilities/blob/master/doc/Command-Reference.md

**- How to verify it**
$ pytest tests/yang_model_tests/test_yang_model.py -v
============================================================================== test session starts ===============================================================================
platform linux2 -- Python 2.7.13, pytest-3.0.6, py-1.4.32, pluggy-0.4.0 -- /usr/bin/python
cachedir: .cache
rootdir: /sonic/src/sonic-yang-models, inifile:
plugins: cov-2.4.0
collected 1 items

tests/yang_model_tests/test_yang_model.py::Test_yang_models::test_run_tests PASSED

============================================================================ 1 passed in 0.50 seconds ============================================================================
* defaults to fields: COPP_GROUP  queue, trap_priority, color, cir, cbs, green_action, yellow_action, red_action
* Mandatory fields: COPP_GROUP  trap_action, meter_type, mode and COPP_TRAP|trap_ids
* Add more tests
@amaneti
Copy link
Contributor Author

amaneti commented Jun 20, 2021

rebased, resolved conflicts.
@dgsudharsan @prsunny @lguohan - please review.

@amaneti
Copy link
Contributor Author

amaneti commented Jun 20, 2021

@arlakshm, @anshuv-mfst - rebased, build passed.

@anshuv-mfst
Copy link

@arlakshm - could you please help with merge, thanks.

@prsunny prsunny merged commit 5acf234 into sonic-net:master Jun 29, 2021
carl-nokia pushed a commit to carl-nokia/sonic-buildimage that referenced this pull request Aug 7, 2021
* SONiC Yang model support for COPP
* Tables: COPP_GROUP, COPP_TRAP.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
YANG YANG model related changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants